<?php
require_once 'Response.php';
require_once 'DB.php';


$id = $_REQUEST['id'];

//2. 查询数据
$pdo = DB::getInstance()->connect();
$stmt = $pdo->query("INSERT `cart`(title,content,num,price,origin_price,type_id,img,create_time) SELECT title,content,num,price,origin_price,type_id,img,create_time FROM goods WHERE goods.id = {$id};
                     alter table `cart` drop id;
                     alter table `cart` add id int not null primary key auto_increment first;
                    ");
$item = $stmt->fetch();

Response::json(200, '成功', $item);